﻿using System;
using System.Configuration;
using System.Diagnostics;

using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;

namespace BizElements.BusinessLayer
{
    /// <summary>Configuration object for a <see cref="AppLogTableTraceListener"/>.</summary>
    [Assembler(typeof(AppLogTableTraceListenerAssembler))]
    public sealed class AppLogTableTraceListenerData : TraceListenerData
    {
        private const string formatterNameProperty = "formatter";

        /// <summary> Initializes a <see cref="AppLogTableTraceListenerData"/>.</summary>
        public AppLogTableTraceListenerData()
        {
        }

        /// <summary>Initializes a named instance of <see cref="AppLogTableTraceListenerData"/> with name and formatter name.</summary>
        /// <param name="name">The name.</param>
        /// <param name="formatterName">The formatter name.</param>        
        public AppLogTableTraceListenerData(string name, string formatterName)
            : this(name, formatterName, TraceOptions.None)
        {
        }

        /// <summary>Initializes a named instance of <see cref="AppLogTableTraceListenerData"/> with name and formatter name.</summary>
        /// <param name="name">The name.</param>
        /// <param name="formatterName">The formatter name.</param>
        /// <param name="traceOutputOptions">The trace options.</param>
        public AppLogTableTraceListenerData(string name, string formatterName, TraceOptions traceOutputOptions)
            : base(name, typeof(AppLogTableTraceListener), traceOutputOptions)
        {
            this.Formatter = formatterName;
        }

        /// <summary>Gets or sets the formatter name.</summary>
        [ConfigurationProperty(formatterNameProperty, IsRequired = false)]
        public string Formatter
        {
            get { return (string)base[formatterNameProperty]; }
            set { base[formatterNameProperty] = value; }
        }
    }
}
